const sendResponse = (res, code, message, data = null) => {
  const response = {
    code,
    message,
    data
  };
  res.status(code).json(response);
};

module.exports = {
  success: (res, data = null, message = 'Success') => {
    sendResponse(res, 200, message, data);
  },
  created: (res, data = null, message = 'Resource created') => {
    sendResponse(res, 201, message, data);
  },
  badRequest: (res, message = 'Bad request') => {
    sendResponse(res, 400, message);
  },
  unauthorized: (res, message = 'Unauthorized') => {
    sendResponse(res, 401, message);
  },
  forbidden: (res, message = 'Forbidden') => {
    sendResponse(res, 403, message);
  },
  notFound: (res, message = 'Resource not found') => {
    sendResponse(res, 404, message);
  },
  conflict: (res, message = 'Conflict') => {
    sendResponse(res, 409, message);
  },
  serverError: (res, message = 'Internal server error') => {
    sendResponse(res, 500, message);
  }
};